# -*- coding: utf-8 -*-
# filename: available.py
import web
import json
from configcenter import configCenter

class Available(object):
    def GET(self):
        try:
	    web.header("Access-Control-Allow-Origin", "*") 
            web.header('content-type','text/json')
            cc = configCenter()
            config = cc.getConfig()
            host = config.get("global", "ip")
            port = config.get("global", "port")
            user = config.get("global", "user")
            pw = config.get("global", "password")
            database = config.get("global", "database")
            db = web.database(dbn='mysql', host=host, port=int(port), user=user, pw=pw, db=database)
            persons = db.select('sign',where='prize_level="-1"')
            pdata = []
            for person in persons:
                pdata.append(person.mobile)
            datadict = {}
            datadict['data'] = pdata
            datadict['result'] = True
           # return "%s('%s')" % (web.input().callback, json.dumps(datadict))
            return json.dumps(datadict)
	except Exception as e:
            return e.args
